package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelType;
import edu.scau.pro.hotel.mapper.HotelTypeMapper;
import edu.scau.pro.hotel.service.IHotelTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelType)表服务实现类
 *
 * @author CJW
 * @since 2022-03-08 09:33:12
 */
@Service("hotelTypeService")
public class HotelTypeServiceImpl implements IHotelTypeService {
    @Resource
    private HotelTypeMapper hotelTypeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param typeId 主键
     * @return 实例对象
     */
    @Override
    public HotelType queryById(Integer typeId) {
        return this.hotelTypeMapper.queryById(typeId);
    }

    /**
     * 查询指定行
     *
     * @param hotelType 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelType> queryAll(HotelType hotelType) {
        return this.hotelTypeMapper.queryAll(hotelType);
    }

    /**
     * 新增数据
     *
     * @param hotelType 实例对象
     * @return 实例对象
     */
    @Override
    public HotelType insert(HotelType hotelType) {
        this.hotelTypeMapper.insert(hotelType);
        return hotelType;
    }

    /**
     * 修改数据
     *
     * @param hotelType 实例对象
     * @return 实例对象
     */
    @Override
    public HotelType update(HotelType hotelType) {
        this.hotelTypeMapper.update(hotelType);
        return this.queryById(hotelType.getTypeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param typeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer typeId) {
        return this.hotelTypeMapper.deleteById(typeId) > 0;
    }
}
